local wdtx__supplyShortageSkill = fk.CreateSkill {
  name = "wdtx__supply_shortage_skill",
}

wdtx__supplyShortageSkill:addEffect("cardskill", {
  name = "wdtx__supply_shortage_skill",
  prompt = "#wdtx__supply_shortage_skill",
  distance_limit = 1,
  mod_target_filter = function(self, to_select, _, user, card, distance_limited)
    local player = to_select
    local from = user
    return from ~= player and not (distance_limited and not self:withinDistanceLimit(from, false, card, player))
  end,
  target_filter = function(self, player, to_select, selected, _, card, extra_data)
    local count_distances = not (extra_data and extra_data.bypass_distances)
    return #selected == 0 and self:modTargetFilter(to_select, selected, player, card, count_distances)
  end,
  target_num = 1,
  on_effect = function(self, room, effect)
    local to = effect.to
    local judge = {
      who = to,
      reason = "wdtx__supply_shortage_skill",
      pattern = ".|.|spade,heart,diamond",
    }
    room:judge(judge)
    local result = judge.card
    if result.suit ~= Card.Club then
      to:skip(Player.Draw)
      if room.logic.class.name == "wdtx_logic" and effect.card:getMark("@weak_hurt") > 0 then
        room:addPlayerMark(to,"@weak_hurt",effect.card:getMark("@weak_hurt") + 1)
        room:handleAddLoseSkills(to, "weak_hurt_skill", nil, false)
      end
    end
    self:onNullified(room, effect)
  end,
  on_nullified = function(self, room, effect)
    room:moveCards{
      ids = room:getSubcardsByRule(effect.card, { Card.Processing }),
      toArea = Card.DiscardPile,
      moveReason = fk.ReasonUse,
      specialName = "self_draws" or "self_discs" or "self_cost",
    }
  end,
})


return wdtx__supplyShortageSkill